package com.thread.lock.money.first;

/**
 * @description:
 * @author: 刘建楼
 * @create: 2021-04-20
 **/
public class Account {

    private String accountNo;
    private double balance;

    // 下面两个方法根据accountNo来重写hashCOde()和equals()方法
    public int hashCode() {
        return accountNo.hashCode();
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        };
        if(obj!=null && obj.getClass()==Account.class){
            Account account = (Account) obj;
            return account.getAccountNo().equals(accountNo);
        }
        return false;
    }


    public Account() {
    }

    public Account(String accountNo, double balance) {
        this.accountNo = accountNo;
        this.balance = balance;
    }

    public String getAccountNo() {
        return accountNo;
    }

    public void setAccountNo(String accountNo) {
        this.accountNo = accountNo;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}
